import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ConfigService } from '@nestjs/config';
import { Others_Swaggers_Base } from './common/others/swaggers';
import { generateModuleImports } from './modules/generateModuleImports.js';
import { generateEntityImports } from './modules/generateEntityImports';

async function bootstrap() {
  if (process.env.DEV_ENV) generateEntityImports();
  if (process.env.DEV_ENV) generateModuleImports();
  const app = await NestFactory.create(AppModule, {});
  //要想swagge发起的请求也在api开头 这个全局设置需要放前面
  const configService = app.get(ConfigService);
  app.setGlobalPrefix(configService.get<string>('APP_URL'));
  Others_Swaggers_Base(app);
  await app.listen(configService.get<string>('APP_PORT'));
}
bootstrap();
